<%@ page contentType="text/html; charset=UTF-8" buffer="16kb"%>
<%@ include file="../include/taglib.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Pragrma", "no-cache");
    response.setDateHeader("Expires", 0);
    Long resid = Long.parseLong(request.getParameter("id"));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>linux综合性能页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<%@ include file="../include/common.jsp"%>
<%@ include file="../include/table.jsp"%>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/progressbar/jquery.progressbar.min.js"></script>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/perf/listPage.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>

<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.jqueryplugin.js"></script>
	
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/common/Xslider.js"></script>
	

<script type="text/javascript">

	var iochart;
	function initLock(){
		if(typeof iochart == undefined || iochart==null){
			iochart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","ioChart1", "100%", "150px", "0", "1" );
		}
	
		$.ajax({
			url : 'real-time!get2LineChart.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				childType:'1202051200000',
				propIds:'120205120000004,120205120000005,120205120000005'
			},
			success : function(dataset) {
				iochart.setJSONData(dataset);
				iochart.render("iolineChart");
			}
		});
	}


	//初始化会话列表
	function initList(){
		//会话列表
		$.ajax({
			type:'post',
			url:'real-time!initDatatables.action',
			data:{resId:<%=resid %>,
				childType:'1202051100000',
				propId:'120205110000001'
			},
			global:false,
			async:false,
			cache:false,
			dataType:'json',
			success:function(data,textStatus){
				var columnArray = data.columns;
				var datas       = data.data;
				var props       = data.props;
				$.each(columnArray,function(index,ob){
					var cols = ob;
					$.each(cols,function(index,ob){
						$('#sessionList > thead > tr').append('<th>'+ob+'</th>');
					});
					
					var tbl = $('#sessionList > tbody ');
					if(datas[index]!=null){
						//构建数据
						$.each(datas[index],function(i,o){
							var dataHtml = (i%2)==0?'<tr class="odd" >': '<tr class="even" >';
								$.each(o,function(t,en){
									dataHtml +='<td>'+en+'</td>';
								});
							dataHtml +='</tr>';
							tbl.append(dataHtml);
					   });
					}
				});
			}
		});		
		
		//死锁会话列表
		$.ajax({
			type:'post',
			url:'real-time!initDatatables.action',
			data:{resId:<%=resid %>,
				childType:'1202050400000',
				propId:'120205040000001'
			},
			global:false,
			async:false,
			cache:false,
			dataType:'json',
			success:function(data,textStatus){
				var columnArray = data.columns;
				var datas       = data.data;
				var props       = data.props;
				$.each(columnArray,function(index,ob){
					var cols = ob;
					$.each(cols,function(index,ob){
						$('#invalidSessionList > thead > tr').append('<th>'+ob+'</th>');
					});
					
					var tbl = $('#invalidSessionList > tbody ');
					if(datas[index]!=null){
						//构建数据
						$.each(datas[index],function(i,o){
							var dataHtml = (i%2)==0?'<tr class="odd" >': '<tr class="even" >';
								$.each(o,function(t,en){
									dataHtml +='<td>'+en+'</td>';
								});
							dataHtml +='</tr>';
							tbl.append(dataHtml);
					   });
					}
				});
			}
		});		
	}
	
	var tcpChart;
	var swapChart;
	var processChart
	var invalidChart
	function initTCP() {
			processChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","processChart11", "100%", "100%", "0", "1" );
			invalidChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","invalidChart22", "100%", "100%", "0", "1" );
		
		
		//进程
		$.ajax({
			url : 'real-time!get2LineChart.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				childType:'1202050700000',
				propIds:'120205070000001,120205070000003,120205070000004'
			},
			success : function(data) {
				processChart.setJSONData(data);
				processChart.render("processDiv");
			}
		});
		
		//内存
		$.ajax({
			url : 'real-time!get2LineChart.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				childType:'1202051000000',
				propIds:'120205100000001,120205100000002,120205100000003'
			},
			success : function(data) {
				invalidChart.setJSONData(data);
				invalidChart.render("memDiv");
			}
		});
	}
	
	
	var fsColChartc;
	var heapChart;
	var cacheRateCol;
	function initBaseInfo(){
			//基本信息
			$.ajax({
				url : 'real-time!getBaseInfo.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					propIds:'attr_110200000000001,prop_110205000000002,prop_110205000000001,prop_110205000000004,prop_110205000000003,prop_110200000000002,prop_110200000000001'
				},
				success : function(data) {
					$('#attr_110200000000001').text(data.attr_110200000000001); //实例名
					$('#prop_110205000000002').text(data.prop_110205000000002); //版本
					$('#prop_110205000000001').text(data.prop_110205000000001); //字符集
					$('#prop_110205000000004').text(data.prop_110205000000004); //创建时间
					$('#prop_110205000000003').text(data.prop_110205000000003); //启动时间
					$('#prop_110200000000002').text(data.prop_110200000000002); //响应时间
					$('#prop_110200000000001').text(data.prop_110200000000001); //状态
					$('#resIp').text(data.ip);
				}
			});
			
			//CPU繁忙率
			$.ajax({
				url : 'real-time!getHLineGauge.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1202050900000',
					maxPropId:'100',
					usePropId:'120205090000003',
					unit:'%'
				},
				success : function(data) {
					if(typeof heapChart == undefined || heapChart == null){
						heapChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/HLinearGauge.swf?ChartNoDataText=没有数据","heapChart1", "100%", "130", "0", "1" );
					}
					heapChart.setJSONData(data);
					heapChart.render("cpuChart");
				}
			});
			
			//设备
			if(typeof cacheRateCol == undefined || cacheRateCol == null){
				cacheRateCol =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","cacheRateCol1", "100%", "130", "0", "1" );
			}
			$.ajax({
				url : 'real-time!get2ColumnChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					detail:1,
					childType:'1202050300000',
					propIds:'120205030000002',
					unit:'%',
					top:'5'
				},
				success : function(data) {
					cacheRateCol.setJSONData(data);
					cacheRateCol.render("cacheRateCol");
				}
			});
			
			//段空闲页数
			if(typeof fsColChartc == undefined || fsColChartc == null){
				fsColChartc =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","fsColChart11", "100%", "130", "0", "1" );
			}
			$.ajax({
				url : 'real-time!get2ColumnChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					detail:1,
					childType:'1202050800000',
					propIds:'120205080000003',
					top:'10',
					unit:'%'
				},
				success : function(data) {
					fsColChartc.setJSONData(data);
					fsColChartc.render("segmentChart");
				}
			});
	}
	
	$(document).ready(function() {
			initBaseInfo();
			initTCP();
			initLock();
			initList();
		    setInterval('initBaseInfo()',60000);
	});
</script>

</head>
<body>

	<div class="column">
		<div class="col-main">
			<!--基本信息-->
			<div class="col-l-extra h-400">
			<h2 class="title-h2 m-0">基本信息</h2>
			<ul class="col-l-ul">
					<li><span class="col-l-ul-l" >数据库类别:</span><span 
								class="col-l-ul-r"><img src="${pageContext.request.contextPath}/style/default/bsm/perf/images/sybase24_24.png"></img></span>
					</li>
					<li><span class="col-l-ul-l" >IP:</span><span id="resIp"
							class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >设备名称:</span><span id="attr_110200000000001"
								class="col-l-ul-r"></span>
					</li>		
					<li><span class="col-l-ul-l" >版本:</span><span id="prop_110205000000002"
								class="col-l-ul-r"></span>
					</li>			
					<li><span class="col-l-ul-l" >产品名称:</span><span id="prop_110205000000001"
								class="col-l-ul-r"></span>
					</li>			
					<li><span class="col-l-ul-l" >驱动版本:</span><span id="prop_110205000000004"
							class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >驱动名称:</span><span id="prop_110205000000003"
								class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >响应时间(ms):</span><span id="prop_110200000000002"
								class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >连接状态:</span><span id="prop_110200000000001"
								class="col-l-ul-r"></span>
					</li>
			   </ul>
			</div>
			<!--@end基本信息-->
			<div class="col-r-main">
				<div class="col-v-rate-extra" >
				  <h2 class="title-h2 m-0">CPU繁忙率</h2>
				  <div id="cpuChart"></div>
				</div>
				<!--@end基本信息-->
				 <div class="col-v-rate-extra f-r">
				   <h2 class="title-h2 m-0">设备空闲大小 TOP5</h2>
				   <div id="cacheRateCol"></div>
			     </div>
			    
			     <div class="col-v-rate-extra" style="width:99%">
		            <h2 class="title-h2 m-0">段空闲页数 TOP10</h2>
			       <div id="segmentChart"></div>
			    </div>
			 </div>   
		  </div>
		</div>
	
	       <div class="column">
				<div class="col-main">
					<div class="col-net-main" >
						<h2 class="title-h2 m-0">进程 [当天趋势图]-[进程数,活动进程数,系统进程数]</h2>
						<div id="processDiv" class=" h-150 w-100"></div>
					</div>
					
					<div class="col-net-main f-r w-48" >
						<h2 class="title-h2 m-0">服务器内存 [当天趋势图]-[内存大小,数据缓存大小,程序缓存大小]</h2>
						<div id="memDiv" class= "col-r-main h-150 w-100"></div>
					</div>
				</div>
	        </div>
	        
	        <div class="column b-1">
					<h2 class="title-h2 m-0">性能统计 [当天趋势图]-[执行AS工作的CPU时间,执行I/O操作的CPU时间,处于空闲状态的CPU时间]</h2>
						<div class="col-net-main p-99">
						    <div id="iolineChart"></div>
					    </div>
	        </div>
		 	
		 	<div class="column b-1">
					<h2 class="title-h2 m-0">会话列表</h2>
				    <table width='100%' cellpadding='0' cellspacing='0' border='0' class='display' id='sessionList'>
				       <thead>
				           <tr>
				           </tr>
				       </thead>
				       <tbody>
				       </tbody>
				    </table>
			</div>
			
		 	<div class="column b-1">
					<h2 class="title-h2 m-0">锁列表</h2>
				   <table width='100%' cellpadding='0' cellspacing='0' border='0' class='display' id='invalidSessionList'>
				       <thead>
				             <tr>
				             </tr>
				       </thead>
				       <tbody>
				       </tbody>
				   </table>
			</div>
			
			<div class="column" style="width:100%;height:5px;"></div>
</body>

</html>